package com.example.find_module.find.fragments.attention;

import com.example.common.entity.BaseEntity;
import com.example.common.mvvm.databus.LiveDataBus;
import com.example.common.mvvm.viewmodel.BaseViewModel;
import com.example.find_module.find.FindModel;
import com.example.find_module.find.fragments.attention.entity.AttbenEntity;
import com.example.find_module.find.fragments.attention.entity.FindEntity;

import java.util.List;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class AttentionViewModel  extends BaseViewModel<AttentionModel> {
    public LiveDataBus<List<AttbenEntity>> attention_list=new LiveDataBus<>();
    @Override
    public void onResult(BaseEntity entity) {
        if (entity instanceof FindEntity){
            FindEntity findEntity= (FindEntity) entity;
            List<AttbenEntity> data = findEntity.data.getData();
            attention_list.postValue(data);
        }

    }

    @Override
    protected void initData() {
        respository.requestAttention()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(this);
    }
}
